echo "Usage:openstack_install.sh <HOST IP>"
echo "Are you specify host IP($1)?"
sleep 5

apt-get update


msg="s/%SERVER%/$1/g"
echo "Install Neutron"
sudo apt-get install -y openvswitch-controller openvswitch-switch openvswitch-datapath-source
sudo apt-get install -y neutron-dhcp-agent neutron-plugin-openvswitch-agent neutron-l3-agent
rm /etc/neutron/neutron.conf
wget -O /etc/neutron/neutron.conf https://conf.googlecode.com/svn/trunk/openstack/neutron/neutron.conf
sudo sed -i $msg /etc/neutron/neutron.conf

rm /etc/neutron/api-paste.ini
wget -O /etc/neutron/api-paste.ini https://conf.googlecode.com/svn/trunk/openstack/neutron/api-paste.ini
sudo sed -i $msg /etc/neutron/api-paste.ini


rm /etc/neutron/dhcp_agent.ini
wget -O /etc/neutron/dhcp_agent.ini https://conf.googlecode.com/svn/trunk/openstack/neutron/dhcp_agent.ini


apt-get -y install openvswitch-switch neutron-plugin-openvswitch-agent
rm -f /etc/init/neutron-plugin-openvswitch-agent.conf
wget -O /etc/init/neutron-plugin-openvswitch-agent.conf https://conf.googlecode.com/svn/trunk/openstack/neutron/neutron-plugin-openvswitch-agent.conf

mkdir /etc/neutron/plugins/ml2
wget -O /etc/neutron/plugins/ml2/ml2_conf.ini https://conf.googlecode.com/svn/trunk/openstack/neutron/ml2_conf.ini
sudo sed -i $msg /etc/neutron/plugins/ml2/ml2_conf.ini

ovs-vsctl add-br br-int
ovs-vsctl add-br br-ex
##ovs-vsctl add-port br-eth1 eth1
#
#
#service neutron-server restart 
#service neutron-plugin-openvswitch-agent restart
#service neutron-dhcp-agent restart
#service neutron-l3-agent restart
#
#neutron net-create sharednet1 --shared --provider:network_type flat --provider:physical_network physnet1
#neutron subnet-create sharednet1 10.1.1.0/24
